﻿<Window x:Class="FLMScan.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:c="clr-namespace:FLMScan"
        xmlns:l="clr-namespace:FLMScan.WPF"    
        xmlns:p="clr-namespace:FLMScan.Properties"
        Title="{x:Static p:Resources.MainWindowTitle}" Width="800" Height="600" Loaded="Window_Loaded" Closed="Window_Closed">
    <Window.Resources>        
        <c:FLMScanViewModel x:Key="flmScanViewModel"/>
        <l:IntToStringConverter x:Key="IntToStringConverter"/>
        <l:DeviceStateToColorConverter x:Key="DeviceStateToColorConverter"/>
    </Window.Resources>
    <Window.DataContext>
        <Binding Source="{StaticResource flmScanViewModel}"/>
    </Window.DataContext>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200" MinWidth="200" />
            <ColumnDefinition Width="1" />
            <ColumnDefinition Width="*" MinWidth="300" />
            <ColumnDefinition Width="1" />
            <ColumnDefinition Width="150" MinWidth="150" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>            
            <RowDefinition MinHeight="340" Height="*"/>
            <RowDefinition MinHeight="180"/>
            <RowDefinition MinHeight="30"  Height="30"/>
        </Grid.RowDefinitions>

        <GridSplitter Name="gridSplitter1" Grid.Column="1" Grid.RowSpan="2" Width="1" BorderBrush="Black" Background="Black" />
        <GridSplitter Name="gridSplitter2" Grid.Column="3" Grid.RowSpan="2" Width="1" BorderBrush="Black" Background="Black" />

        <StackPanel Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="1" Grid.RowSpan="2" Orientation="Vertical" Background="#FFBEBEBE" VerticalAlignment="Stretch">
            <Label Content="{x:Static p:Resources.MainWindowColumnHeaderPrepare}" Name="labelPrepare" HorizontalAlignment="Center" FontSize="20" />
            <Button Content="{x:Static p:Resources.MainWindowButtonPreferences}" Height="23" HorizontalAlignment="Center" Name="buttonPreferences" VerticalAlignment="Top" Width="99" Command="{Binding Path=EditPreferencesCommand, Source={StaticResource flmScanViewModel}}" Margin="0,5,0,5"/>
            <Button Content="{x:Static p:Resources.MainWindowButtonCalibrate}" Height="23" HorizontalAlignment="Center" Name="buttonCalibrate" VerticalAlignment="Top" Width="99" Command="{Binding Path=CalibrateCommand, Source={StaticResource flmScanViewModel}}" Margin="0,5,0,5"/>
            <StackPanel Orientation="Vertical">
                <Label Content="{x:Static p:Resources.MainWindowStaticTextPrerequisites}" Height="28" Name="labelPrerequisites" />
                <StackPanel VerticalAlignment="Top" Orientation="Horizontal" Margin="5,0,0,0">
                    <RadioButton Height="16" Name="radioButtonLaserPower" GroupName="Group4" Background="{Binding Path=LaserPowerState, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource DeviceStateToColorConverter}}" Margin="5,0,0,0"/>
                    <Label Content="{x:Static p:Resources.MainWindowRadioButtonTextLaserPower}" Height="28" Name="labelLaserPower" />
                </StackPanel>
                <StackPanel VerticalAlignment="Top" Orientation="Horizontal" Margin="5,0,0,0">
                    <RadioButton Height="16" IsEnabled="True" Name="radioButtonStepperPower" GroupName="Group4" Background="{Binding Path=StepperPowerState, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource DeviceStateToColorConverter}}" Margin="5,0,0,0"/>
                    <Label Content="{x:Static p:Resources.MainWindowRadioButtonTextStepperPower}" Height="28" Name="labelStepperPower" />
                </StackPanel>
                <StackPanel VerticalAlignment="Top" Orientation="Horizontal" Margin="5,0,0,0">
                    <RadioButton Height="16" IsEnabled="True" Name="radioButtonLightPower" GroupName="Group4" Background="{Binding Path=LightPowerState, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource DeviceStateToColorConverter}}" Margin="5,0,0,0"/>
                    <Label Content="{x:Static p:Resources.MainWindowRadioButtonTextLightPower}" Height="28" Name="labelLightOn" />
                </StackPanel>
                <StackPanel VerticalAlignment="Top" Orientation="Horizontal" Margin="5,0,0,0">
                    <RadioButton Height="16" IsEnabled="True" Name="radioButtonWebcamConnection" GroupName="Group4" Background="{Binding Path=WebcamConnectionState, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource DeviceStateToColorConverter}}" Margin="5,0,0,0"/>
                    <Label Content="{x:Static p:Resources.MainWindowRadioButtonTextWebcamDetected}" Height="28" Name="labelWebcamDetected" />
                </StackPanel>
                <StackPanel VerticalAlignment="Top" Orientation="Horizontal" Margin="5,0,0,0">
                    <RadioButton Height="16" IsEnabled="True" Name="radioButtonArduinoConnection" GroupName="Group4" Background="{Binding Path=ArduinoConnectionState, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource DeviceStateToColorConverter}}" Margin="5,0,0,0"/>
                    <Label Content="{x:Static p:Resources.MainWindowRadioButtonTextArduinoDetected}" Height="28" Name="labelArduinoDetected" />
                </StackPanel>
            </StackPanel>

            <StackPanel VerticalAlignment="Top" Orientation="Vertical">
                <Label Content="{x:Static p:Resources.MainWindowStaticTextPutObjectOnTable}" Height="28" Name="labelPutObjectOnTable" Margin="0,20,0,0" />
                <Image Height="75" Width="100" Name="imageScanTableSymbol" OpacityMask="Black" Source="/FLMScan;component/Resources/ObjectOnTable.png" />
            </StackPanel>


            <StackPanel VerticalAlignment="Top" Orientation="Vertical">
                <Label Content="{x:Static p:Resources.MainWindowStaticTextCloseDoor}" Height="28" Name="labelCloseDoor" Margin="0,20,0,0" />

                <StackPanel VerticalAlignment="Top" Orientation="Horizontal" Margin="5,0,0,0">
                    <RadioButton Height="16" IsEnabled="True" Name="radioButtonDoorContactState" GroupName="Group4" Background="{Binding Path=DoorContactState, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource DeviceStateToColorConverter}}" Margin="5,0,0,0"/>
                    <Label Content="{x:Static p:Resources.MainWindowRadioButtonTextDoorOpen}" Height="28" Name="labelDoorStatus" Margin="20,0,0,0" />
                </StackPanel>
            </StackPanel>

        </StackPanel>

        <StackPanel Grid.Column="2" Grid.Row="0" Grid.RowSpan="2" Orientation="Vertical" Background="#FFBEBEBE">
            <Label Content="{x:Static p:Resources.MainWindowColumnHeaderScan}" Name="labelScan" HorizontalAlignment="Center" FontSize="20" />
            <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" MinWidth="300" MinHeight="280">
                <Canvas Name="canvasWebcam" Background="Black" MinWidth="360" MinHeight="270" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Image Name="imageWebcam" MinWidth="360" MinHeight="270" HorizontalAlignment="Center" VerticalAlignment="Center" />
                </Canvas>
            </StackPanel>
                    
        <StackPanel VerticalAlignment="Top" Grid.Column="2" Grid.Row="1" Orientation="Vertical" Background="#FFBEBEBE" Margin="0,0,0,0">
                <StackPanel Orientation="Horizontal" VerticalAlignment="Stretch" HorizontalAlignment="Center" MinHeight="30">
                    <Label Content="{x:Static p:Resources.MainWindowStaticTextStep}" Name="labelProgressStep"/>
                    <Label Name="labelProgressCurrent" Content="{Binding Path=CurrentScanStep, Mode=OneWay, Converter={StaticResource IntToStringConverter}}"/>
                    <Label Content="{x:Static p:Resources.MainWindowStaticTextStepOf}" Name="labelProgressOf"/>
                    <Label Name="labelProgressTotal" Content="{Binding Path=TotalScanSteps, Mode=OneWay, Converter={StaticResource IntToStringConverter}}"/>
                    <ProgressBar Height="10" Name="progressBar" Width="100" Maximum="{Binding Path=TotalScanSteps, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Value="{Binding Path=CurrentScanStep, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
                    <Label Content="{x:Static p:Resources.MainWindowStaticTextEstimatedTime}" Name="labelProgressEstimate"/>
                    <Label Name="labelProgressEstimateTime" Content="{Binding Path=RemainingTime, Mode=OneWay}"/>
                </StackPanel>

            </StackPanel>
            <StackPanel VerticalAlignment="Top" Orientation="Horizontal" HorizontalAlignment="Center">
                <Button Content="{x:Static p:Resources.MainWindowButtonStart}" Name="buttonStartScan" VerticalAlignment="Top" Height="50" Width="75" Command="{Binding Path=StartScanCommand, Source={StaticResource flmScanViewModel}}" />
                <Button Content="{x:Static p:Resources.MainWindowButtonStop}" Name="buttonStopScan" VerticalAlignment="Top" Height="50" Width="75" Command="{Binding Path=StopScanCommand, Source={StaticResource flmScanViewModel}}" />
            </StackPanel>
            
            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal">
                <RadioButton Content="{x:Static p:Resources.MainWindowRadioButtonTextStepsDraft}" HorizontalAlignment="Left" VerticalAlignment="Center" Name="radioButtonDraftSteps" IsChecked="{Binding Path=DraftScanState, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding Path=DraftScanEnabled, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" GroupName="Group3" />
                <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" Name="textBoxResolutionDraft" Width="38" Margin="5,0" Text="{Binding Path=DraftScanSteps, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource IntToStringConverter}}" IsEnabled="{Binding Path=DraftScanStepsEnabled, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
                <Label Content="{x:Static p:Resources.MainWindowStaticTextEqualsDraft}" VerticalAlignment="Center" Name="labelDraftStepsTime" />
                <Label Content="{x:Static p:Resources.MainWindowStaticTextEqualsDraftUnit}" Name="labelDraftStepsTimeUnits" />
            </StackPanel>
            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Horizontal" Margin="5,5">
                <RadioButton Content="{x:Static p:Resources.MainWindowRadioButtonTextStepsFinal}" VerticalAlignment="Center" Name="radioButtonFinalSteps" IsChecked="{Binding Path=FinalScanState, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding Path=FinalScanEnabled, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" GroupName="Group3" />
                <TextBox HorizontalAlignment="Left" VerticalAlignment="Center" Name="textBoxResolutionFinal" Width="38" Margin="5,0" Text="{Binding Path=FinalScanSteps, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource IntToStringConverter}}" IsEnabled="{Binding Path=FinalScanStepsEnabled, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
                <Label Content="{x:Static p:Resources.MainWindowStaticTextEqualsFinal}" VerticalAlignment="Center" Name="labelFinalStepsTime" />
                <Label Content="{x:Static p:Resources.MainWindowStaticTextEqualsFinalUnit}" Name="labelFinalStepsTimeUnits" />
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Background="#FFBEBEBE">
                <TextBox Text="{x:Static p:Resources.MainWindowStaticTextStepsDescription}" Width="350" HorizontalAlignment="Stretch" AcceptsReturn="False" TextWrapping="Wrap" Background="#FFBEBEBE" IsEnabled="True" IsReadOnly="True"></TextBox>                
            </StackPanel>
            <StackPanel>
                <Button Content="{x:Static p:Resources.MainWindowButtonPreview}" HorizontalAlignment="Center" Name="buttonPreview" VerticalAlignment="Center" Width="75" Command="{Binding Path=PreviewScanCommand, Source={StaticResource flmScanViewModel}}"/>
            </StackPanel>
        </StackPanel>

        <StackPanel Grid.Column="4" Grid.RowSpan="2" Orientation="Vertical" Background="#FFBEBEBE" HorizontalAlignment="Stretch">
            <Label Content="{x:Static p:Resources.MainWindowColumnHeaderExport}" Name="labelExport" HorizontalAlignment="Center" FontSize="20" />
            <RadioButton Content="{x:Static p:Resources.MainWindowRadioButtonTextExportImages}" Height="16" Name="radioButtonExportImages" IsChecked="{Binding Path=ImageExportState, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" GroupName="Group1" />
            <RadioButton Content="{x:Static p:Resources.MainWindowRadioButtonTextExport3DData}" Height="16" Name="radioButtonExport3DData" IsChecked="{Binding Path=GeometryExportState, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="5,0,0,0" GroupName="Group1" />
            <RadioButton Content="{x:Static p:Resources.MainWindowRadioButtonTextExportSTL}" Height="16" Name="radioButtonExportSTL" IsChecked="{Binding Path=GeometryExportStateStl, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10,0,0,0" GroupName="Group2" />
            <RadioButton Content="{x:Static p:Resources.MainWindowRadioButtonTextExportPLY}" Height="16" Name="radioButtonExportPLY" IsChecked="{Binding Path=GeometryExportStatePly, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10,0,0,0" GroupName="Group2" />

            <Button Content="{x:Static p:Resources.MainWindowButtonSave}" Height="23" HorizontalAlignment="Stretch" Name="buttonSave" Margin="5,0,5,0" Command="{Binding Path=SaveCommand, Source={StaticResource flmScanViewModel}}"/>
            <TextBox Height="23" HorizontalAlignment="Stretch" Name="textBoxFileName" VerticalAlignment="Top" Margin="5,0,5,0" Text="{Binding Path=FileName, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"/>
        </StackPanel>

        <StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="5" Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Top">
            <TextBox Height="30 " Name="richTextBoxStatus" Text="{Binding Path=StatusMessage, Mode=OneWay}" FontSize="20" IsReadOnly="True"/>            
        </StackPanel>        
    </Grid>
</Window>
